﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Automobile.service.Model;
using Automobile.service.BLL;
using System.Data;

namespace Automobile.service.UI
{
    public partial class Stock : System.Web.UI.Page
    {
        StockBll bll = new StockBll();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadData();
            }
        }

        private void LoadData()
        {
            this.Repeater1.DataSource = bll.Stock();
            this.Repeater1.DataBind();
        }

        
        protected void Repeater1_ItemCommand1(object source, RepeaterCommandEventArgs e)
        {
             string name = e.CommandName;//获取当前要执行命令名称
            string id = e.CommandArgument.ToString();//获取当前绑定的主键

            switch (name)
            {
                case "del":
                    if (bll.DeleStock(Convert.ToInt32(id)) > 0)
                    {
                        Response.Write("<script>alert('删除成功');</script>");
                        LoadData();
                    }
                    break;
                case "upd":
                    Response.Redirect("UpdateStock.aspx?fid=" + id);
                    break;
            }
        }
    }
}